import request from '@/utils/request'

// 查询空调设备运行日志列表
export function getAirConditionerLogs(data) {
  return request({
    url: '/airconditioner/device/transmitter/logs',
    method: 'post',
    data: data
  })
}

// 查询空调设备状态信息
export function getAirConditionerStatus(deviceId) {
  return request({
    url: '/device/airconditioner/status/' + deviceId,
    method: 'get'
  })
}

// 获取空调运行历史数据
export function getAirConditionerData(query) {
  return request({
    url: '/device/airconditioner/history',
    method: 'get',
    params: query
  })
}

// 保存空调参数设置
export function saveAirConditionerParameters(data) {
  return request({
    url: '/device/airconditioner/parameters',
    method: 'post',
    data: data
  })
}

// 获取空调参数设置
export function getAirConditionerParameters() {
  return request({
    url: '/device/airconditioner/parameters',
    method: 'get'
  })
}

// 清空空调运行日志
export function clearAirConditionerLogs() {
  return request({
    url: '/device/airconditioner/logs/clear',
    method: 'delete'
  })
}

// 获取空调运行状态图表数据
export function getAirConditionerChart(data) {
  return request({
    url: '/airconditioner/device/detail/chart',
    method: 'post',
    data: data
  })
}

// 空调设备控制
export function controlAirConditioner(data) {
  return request({
    url: '/device/airconditioner/control',
    method: 'post',
    data: data
  })
}

// 获取空调设备列表
export function getAirConditionerList(query) {
  return request({
    url: '/device/airconditioner/list',
    method: 'get',
    params: query
  })
}

// 获取空调能耗数据
export function getAirConditionerEnergyData(query) {
  return request({
    url: '/device/airconditioner/energy',
    method: 'get',
    params: query
  })
}

// 获取空调设备管理列表（页面初始化设备源）
// 后端接口：GET /airconditioner/device/manage
export function getAirConditionerManage() {
  return request({
    url: '/airconditioner/device/manage',
    method: 'get'
  })
}

// 更新空调设备参数（编辑详情保存）
// 后端接口：PUT /airconditioner/device/manage/{id}
// id 为当前选中设备的 id，data 为 TransmitterDevice 结构
export function updateAirConditionerDevice(id, data) {
  return request({
    url: `/airconditioner/device/manage/${id}`,
    method: 'put',
    data: data
  })
}
